﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint.Administration;
using Microsoft.SharePoint;

namespace Inline.SharePoint.SPWebConfigCleaner.ConsoleApp
{

    class Program
    {

        static void Main(string[] args)
        {

            // Create some dummy web.config chances
            using (SPSite site = new SPSite("http://inlinesp2010dev"))
            {

                SPWebApplication webApp = site.WebApplication;

                SPWebConfigModification myModification = new SPWebConfigModification();
                myModification.Path = "configuration/system.webServer/modules";
                myModification.Name = "DummyConfig001";
                myModification.Sequence = 0;
                myModification.Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode;
                myModification.Value = @"<add name=""DummyModule001"" type=""FullAssemblyName001"" />";

                webApp.WebConfigModifications.Add(myModification);
                webApp.Update();
                webApp.WebService.ApplyWebConfigModifications();

                //for (int i = 0; i < 5; i++)
                //{

                //    SPWebConfigModification myModification = new SPWebConfigModification();
                //    myModification.Path = "configuration/system.webServer/modules";
                //    myModification.Name = "DummyConfig" + i;
                //    myModification.Sequence = 0;
                //    myModification.Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode;
                //    myModification.Value = @"<add name=""DummyModule"" type=""FullAssemblyName"" />";

                //    webApp.WebConfigModifications.Add(myModification);
                //    webApp.Update();
                //    webApp.WebService.ApplyWebConfigModifications();

                //}

            }

        }

    }

}
